home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 March / EnigmA AMIGA RUN 05 (1996)(G.R. Edizioni)(IT)[!][issue 1996-03][Skylink CD IV].iso / earcd / program / sprprcdr.lha / Curves.AMOS / Curves.amosSourceCode
AMOS Source Code  |  1996-01-26  |  3KB  |  94 lines

  1. '   ******************************************************** 
  2. '   ***                                                  *** 
  3. '   ***              Curve Drawing Procedures            *** 
  4. '   ***                                                  *** 
  5. '   ***                        by                        *** 
  6. '   ***                                                  *** 
  7. '   ***                   Joseph Bolin                   *** 
  8. '   ***                                                  *** 
  9. '   ******************************************************** 
  10.  
  11. Dim XP(10),YP(10)
  12. Screen Open 0,320,200,4,Lowres
  13. Curs Off : Flash Off : Cls 0
  14. Palette $0,$FFF,$F00,$B0F
  15. Ink 1 : _CURVE3[0,100,319,100,160,0,30]
  16. Ink 2 : _CURVE4[0,100,319,100,160,0,160,199,30]
  17. For P=1 To 4
  18.    Read XP(P),YP(P) : Ink 1 : Bar XP(P)-1,YP(P)-2 To XP(P)+1,YP(P)+2
  19. Next 
  20. Ink 3 : _CURVEMANY[4,30]
  21.  
  22. Data 1,1
  23. Data 318,1
  24. Data 1,100
  25. Data 100,198
  26.  
  27. Procedure _CURVE3[XB,YB,XE,YE,XC,YC,S]
  28.  
  29.    ' Inputs: XB,YB  Beginning coordinate of curve 
  30.    '         XE,YE  End coordinate of curve 
  31.    '         XC,YC  Control coordinate
  32.    '         S      Number of lines in curve
  33.    '
  34.    ' Output: Draws a 3 point curve on the current screen in the current color   
  35.    
  36.    Plot XB,YB
  37.    For ST=0 To S
  38.       X1=XB-((XB-XC)*ST)/S : Y1=YB-((YB-YC)*ST)/S
  39.       X2=XC-((XC-XE)*ST)/S : Y2=YC-((YC-YE)*ST)/S
  40.       X=X1-((X1-X2)*ST)/S : Y=Y1-((Y1-Y2)*ST)/S
  41.       Draw To X,Y
  42.    Next 
  43. End Proc
  44. Procedure _CURVE4[XB,YB,XE,YE,XC,YC,XT,YT,S]
  45.  
  46.    ' Inputs: XB,YB  Beginning coordinate of curve 
  47.    '         XE,YE  End coordinate of curve 
  48.    '         XC,YC  Control coordinate
  49.    '         XT,YT  Second control coordinate 
  50.    '         S      Number of lines in curve
  51.    '
  52.    ' Output: Draws a 4 point curve on the current screen in the current color   
  53.    
  54.    Plot XB,YB
  55.    For ST=0 To S
  56.       X1=XB+((XC-XB)*ST)/S : Y1=YB+((YC-YB)*ST)/S
  57.       X2=XC+((XT-XC)*ST)/S : Y2=YC+((YT-YC)*ST)/S
  58.       X3=XT+((XE-XT)*ST)/S : Y3=YT+((YE-YT)*ST)/S
  59.       X4=X1+((X2-X1)*ST)/S : Y4=Y1+((Y2-Y1)*ST)/S
  60.       X5=X2+((X3-X2)*ST)/S : Y5=Y2+((Y3-Y2)*ST)/S
  61.       X=X4+((X5-X4)*ST)/S : Y=Y4+((Y5-Y4)*ST)/S
  62.       Draw To X,Y
  63.    Next 
  64. End Proc
  65. Procedure _CURVEMANY[N,S]
  66.  
  67.    ' Inputs: N          Number of points in curve   
  68.    '         S          Number of lines in curve  
  69.    '         XP(),YP()  Coordinates of points of the curve  
  70.    '             XP(1),YP(1) are the starting coordinates 
  71.    '             XP(N),YP(N) are the ending coordinates 
  72.    '             the points between 1 and N are the control points
  73.    '
  74.    ' Output: Draws a multiple point curve on the current screen 
  75.    '             in the current color 
  76.    
  77.    Dim X(N),Y(N)
  78.    Shared XP(),YP()
  79.    Plot XB,YB
  80.    For ST=0 To S
  81.       For P=1 To N
  82.          X(P)=XP(P) : Y(P)=YP(P)
  83.       Next 
  84.       L=N
  85.       LP:
  86.       For P=1 To L-1
  87.          X(P)=X(P)+((X(P+1)-X(P))*ST)/S
  88.          Y(P)=Y(P)+((Y(P+1)-Y(P))*ST)/S
  89.       Next 
  90.       Dec L : If L>1 Then Goto LP
  91.       SK:
  92.       Draw To X(1),Y(1)
  93.    Next 
  94. End Proc